package com.sphd.restaurantsystem.presenter;


import com.android.volley.VolleyError;
import com.sphd.restaurantsystem.info.CardInfo;
import com.sphd.restaurantsystem.info.RestaurantInfo;
import com.sphd.restaurantsystem.model.EticketModelImpl;
import com.sphd.restaurantsystem.view.EticketView;

/**
 * Created by Hu on 2016/12/15
 */

public class EticketPresenterImpl implements EticketPresenter {
    EticketModelImpl eticketModel;
    EticketView eticketView;

    public EticketPresenterImpl(EticketView eticketView) {
        this.eticketView = eticketView;
        eticketModel = new EticketModelImpl();
    }

    @Override
    public void addData(String url) {
        eticketView.showLoading();
        eticketModel.sendUrl(url, this);
    }

    @Override
    public void sendError(VolleyError error) {

    }

    @Override
    public void recCoupon(CardInfo couponInfo) {
        eticketView.recGoupon(couponInfo);
        eticketView.dissLoading();
    }

    @Override
    public void doResUel(String url) {
        eticketModel.doResUrl(url, this);
    }

    @Override
    public void recRes(int res) {
        if (res == 1) {
            eticketView.recOk();
        } else {
            eticketView.recFaile();
        }
        eticketView.dissLoading();
    }

    @Override
    public void getResInfo(String url) {
        eticketView.showLoading();
        eticketModel.getMsgUrl(url, this);
    }

    @Override
    public void recMsg(RestaurantInfo restaurantInfo) {
        eticketView.recMsg(restaurantInfo);
        eticketView.dissLoading();
    }
}